package com.binyouwei.designpatterns.behavior.visitor;


/**
 * @author 宾有为
 * Created on 2024/7/15 22:31
 * Social homepage: https://blog.csdn.net/baidu_41616022
 * @desc 访问者模式 - 允许你向一组已经存在的类添加新功能，而且无需修改这些类。
 **/
public class VisitorMain {
    public static void main(String[] args) {
        VisitorCircle circle = new VisitorCircle(5);
        VisitorRectangle rectangle = new VisitorRectangle(4, 6);

        VisitorAreaCalculator areaCalculator = new VisitorAreaCalculator();
        circle.accept(areaCalculator);
        rectangle.accept(areaCalculator);

        VisitorPerimeterCalculator perimeterCalculator = new VisitorPerimeterCalculator();
        circle.accept(perimeterCalculator);
        rectangle.accept(perimeterCalculator);
    }
}
